<?php
/**
 * 默认展示页面
 *
 *
 *
 * @copyright  Copyright (c) 2014-2015 TuntronKJ Inc. (http://www.tuntron.com)
 * @license    http://www.tuntron.com
 * @link       http://www.tuntron.com
 * @since      File available since Release v1.1
 */
defined('InTuntronKJ') or exit('Access Invalid!');
class orderlistControl extends BaseLotteryHallControl{
	public function indexOp(){
		
		$user_model = Model('member');
		$cash_model = Model('cash');
		$uid = $_SESSION['uid'];
		$memberinfo = $user_model->getMemberInfo(array('uid'=>$uid));
		
		$param = array();
		$page = $_GET['pageIndex']?$_GET['pageIndex']:1;
		$start = 10*$page-10;
		
		$fromTime = strtotime($_GET['start']);
		$toTime = strtotime($_GET['end']);
		$type = $_GET['type'];						//提现or充值
		
		if($fromTime && $toTime){
			$fromTime = $fromTime+3600*3;
			$toTime = $toTime+3600*3;
		}else{
			$today_zero = strtotime('today');
			$time = time();
			$fromTime = $today_zero+3600*3;			//查询起始时间
			if($fromTime > $time){
				$toTime = $fromTime;				//查询结束时间
				$fromTime = $today_zero-3600*21;
			}else{
				$toTime = $fromTime+3600*24;
			}			
		}
		$param['beginDate'] = date('Y-m-d',$fromTime);
		$param['endDate'] = date("Y-m-d",$toTime);
		$condition['actionTime'] = array('between',$fromTime.','.$toTime);
		$condition['uid'] = $uid;
		
		if($type == "withdraw"){
			//提现记录
			$order_list = $cash_model->getCashList($condition,'','',$start.',10','id asc');
			$order_count = $cash_model->getCashCount($condition);
		}
		elseif($type == "recharge"){
			//充值记录
			$order_list = $cash_model->getRechargeList($condition,'','',$start.',10','id asc');
			$order_count = $cash_model->getRechargeCount($condition);
		}
		
		if($order_count){
			if($order_count%10 == 0){
				$totalpage = $order_count/10;
			}else{
				$totalpage = intval($order_count/10)+1;
			}
		}else{
			$order_count = 0;
			$totalpage = 1;
		}


		Tpl::output('order_list',$order_list);
		Tpl::output('memberinfo',$memberinfo);
		Tpl::output('type',$type);
		Tpl::output('param',$param);
		Tpl::output('page',$page);
		Tpl::output('totalpage',$totalpage);
		Tpl::output('count',count($order_list));		
		Tpl::showpage('orderlist');
	}



}
